﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class administration_profile : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }


    protected void cbRole_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.DataSourceLoad();
    }


    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (!listboxProfiles.Items.Contains(listboxPrograms.SelectedItem) && (listboxPrograms.SelectedItem != null))
        {
            clsProfile objProfile = new clsProfile();
            objProfile.IdProgram = Convert.ToInt32(listboxPrograms.SelectedValue);
            objProfile.IdRole = Convert.ToInt32(cbRole.SelectedValue);
            objProfile.Insert();
            DataSourceLoad();
            lblMessage.Text = "";
        }
        else
        {
            lblMessage.Text = "Must make the appropriate selection.";
        }
    }

    private void DataSourceLoad()
    {
        listboxProfiles.DataSourceID = "ODSConsultProfileID";
    }

    protected void btnRemove_Click(object sender, EventArgs e)
    {
        if ((listboxProfiles.SelectedItem != null))
        {
            clsProfile objProfile = new clsProfile();
            objProfile.ID = Convert.ToInt32(listboxProfiles.SelectedValue);
            objProfile.Delete();
            DataSourceLoad();
            lblMessage.Text = "";
        }
        else
        {
            lblMessage.Text = "Must make the appropriate selection.";
        }
    }
}
